﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DirectedGraphCycle
{
    class FindAllCycle
    {
        protected ArrayList cycles = null;
        protected int[][] adjacencyListOriginal = null;
        protected bool[] blocked = null;
        protected ArrayList[] B = null;
        protected ArrayList stack = null;
        protected int numNodes = 0;

        public void InitGraph(int[][] adjacencyList)
        {
            this.adjacencyListOriginal = adjacencyList;
            this.numNodes = this.adjacencyListOriginal.Length;
        }

        public virtual ArrayList getAllCycles()
        {
            return new ArrayList();
        }

        public string printAllCycles()
        {
            string allCycles = string.Empty;
            ArrayList cycles = getAllCycles();
            for (int i = 0; i < cycles.Count; i++)
            {
                ArrayList cycle = (ArrayList)cycles[i];
                for (int j = 0; j < cycle.Count; j++)
                {
                    int node = (int)cycle[j];
                    if (j < cycle.Count - 1)
                    {
                        allCycles += node + " -> ";
                    }
                    else
                    {
                        allCycles += node;
                    }
                }
                allCycles += "\n";
            }

            return allCycles;
        }

    }
}
